package com.live.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.live.model.Apply;
import com.live.service.ApplyService;

@WebServlet("/updateApply")
public class UpdateApplyController extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private ApplyService applyService ;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		applyService =new ApplyService();
		int id = Integer.parseInt(request.getParameter("id"));
		int start = Integer.parseInt(request.getParameter("start"));
		String remarks = request.getParameter("remarks").trim();
		Apply apply = new Apply();
		apply.setId(id);
		apply.setRemarks(remarks);
		apply.setStart(start);
		int rel = applyService.editApply(apply);
		
		String strRel = rel > 0 ?"success":"error"; 
		response.getOutputStream().write(strRel.getBytes());
	}
}

